package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.DailyProject;
import com.zygh.policeasset.pojo.FileModification;
import com.zygh.policeasset.pojo.UploadFile;
import com.zygh.policeasset.pojo.vo.ProjectInfoVO;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

@Mapper
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/DailyProjectMapper.class */
public interface DailyProjectMapper {
    @Insert({"insert into daily_project (asset_num,project_name,engineering_content,application_time,approval_time,acceptance_time,construction_unit,settlement_amount,registration_amount,remark,category,data_labels_id,flow_no) values(#{assetNum},#{projectName},#{engineeringContent},#{applicationTime},#{approvalTime},#{acceptanceTime},#{constructionUnit},#{settlementAmount},#{registrationAmount},#{remark},#{category},#{dataLabelsId},#{flowNo})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer add(DailyProject dailyProject);

    @Select({"<script> SELECT d.*,c.`company_name`,af.approval_steps_id as approvalStepsId,af.app_status,u.name as userName FROM daily_project d  LEFT JOIN `company` c ON d.`construction_unit` = c.`id` left join audit_flow af on d.flow_no = af.flow_no left join user u on af.applicant = u.id <where>  <if test='assetNewStatus != null and userId == null'> and d.asset_new_status  = #{assetNewStatus} </if><if test='assetNewStatus != null and userId != null'> and nap.approval_status  = #{assetNewStatus} </if><if test='company != null and company.length &gt; 0 ' > and d.construction_unit  = #{company} </if><if test='category != null and category.length &gt; 0 ' > and d.category  = #{category} </if><if test='projectName != null and projectName.length &gt; 0 ' > and d.project_name  like concat('%',#{projectName},'%') </if><if test='dataLabelsId != null  ' > and d.data_labels_id = #{dataLabelsId} </if><if test='userId != null '> and af.applicant=#{userId} </if><if test=' status != null'> and af.app_status = #{status} </if><if test='combined != null'> and d.registration_amount = #{combined} </if></where> order by id desc</script>"})
    @Results(id = "dailyProjectMap", value = {@Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER),
            @Result(column = "asset_num", property = "assetNum", jdbcType = JdbcType.VARCHAR),
            @Result(column = "project_name", property = "projectName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "engineering_content", property = "engineeringContent", jdbcType = JdbcType.VARCHAR),
            @Result(column = "application_time", property = "applicationTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "approval_time", property = "approvalTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "acceptance_time", property = "acceptanceTime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "construction_unit", property = "constructionUnit", jdbcType = JdbcType.VARCHAR),
            @Result(column = "settlement_amount", property = "settlementAmount", jdbcType = JdbcType.VARCHAR),
            @Result(column = "registration_amount", property = "registrationAmount", jdbcType = JdbcType.VARCHAR),
            @Result(column = "remark", property = "remark", jdbcType = JdbcType.VARCHAR),
            @Result(column = "asset_new_status", property = "assetNewStatus", jdbcType = JdbcType.VARCHAR),
            @Result(column = "company_name", property = "companyName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "data_labels_id", property = "dataLabelsId", jdbcType = JdbcType.VARCHAR),
            @Result(property = "startProvisionDate", column = "start_provision_date"),
            @Result(property = "certificateNum", column = "certificate_num"),
            @Result(property = "appStatus", column = "app_status"),
            @Result(property = "flowNo", column = "flow_no")})
    List<DailyProject> findAll(@Param("assetNewStatus") Integer assetNewStatus,
                               @Param("company") String company,
                               @Param("category") String category,
                               @Param("projectName") String projectName,
                               @Param("dataLabelsId") Integer dataLabelsId,
                               @Param("userId") Integer userId,
                               @Param("status") Integer status,
                               @Param("combined") Double combined);

    @Delete({"delete from daily_project where id = #{iuploadfiled}"})
    Integer delete(Integer num);

    @Select({"<script> SELECT d.*,d.id as projectNo,af.approval_steps_id as approvalStepsId, c.`company_name`,af.app_status,u.name as userName FROM daily_project d LEFT JOIN `company` c ON d.`construction_unit` = c.`id` left join audit_flow af on d.flow_no = af.flow_no left join user u on af.applicant = u.id <where>  <if test='id != null '> and d.id  = #{id} </if></where></script>"})
    @ResultMap({"dailyProjectMap"})
    DailyProject findById(@Param("id") Integer num);

    @Update({"<script>update daily_project <set><if test='assetNum != null and assetNum.length &gt; 0'>asset_num=#{assetNum},</if><if test='projectName != null and projectName.length &gt; 0'>project_name=#{projectName},</if><if test='engineeringContent != null and engineeringContent.length &gt; 0'>engineering_content=#{engineeringContent},</if><if test='applicationTime != null and applicationTime.length &gt; 0'>application_time=#{applicationTime},</if><if test='approvalTime != null and approvalTime.length &gt; 0'>approval_time=#{approvalTime},</if><if test='acceptanceTime != null and acceptanceTime.length &gt; 0'>acceptance_time=#{acceptanceTime},</if><if test='settlementAmount != null and settlementAmount.length &gt; 0'>settlement_amount=#{settlementAmount},</if><if test='constructionUnit != null and constructionUnit.length &gt; 0'>construction_unit=#{constructionUnit},</if><if test='registrationAmount != null and registrationAmount.length &gt; 0'>registration_amount=#{registrationAmount},</if><if test='remark != null and remark.length &gt; 0'>remark=#{remark},</if><if test='category != null and category.length &gt; 0'>category=#{category},</if></set>where id = #{id}</script>"})
    Integer update(DailyProject dailyProject);

    @Update({"update daily_project set asset_new_status = #{assetNewStatus} where id = #{id}"})
    Integer updateByid(@Param("assetNewStatus") Integer num, @Param("id") Integer num2);

    @Update({"update daily_project set start_provision_date = #{startProvisionDate}, certificate_num = #{certificateNum} where id = #{id}"})
    Integer updateSPD(@Param("startProvisionDate") String str, @Param("certificateNum") String str2, @Param("id") Integer num);

    @Select({"select category from daily_project where id=#{id}"})
    String findTypeById(Integer num);

    @Update({"update daily_project set asset_new_status = #{assetApprovalStatus} where id = #{id}"})
    Integer updateDaAssetApprovalStatus(@Param("id") Integer num, @Param("assetApprovalStatus") Integer num2);

    @Select({"select count(*) from daily_project where asset_new_status in (1,2)  and id = #{id}"})
    Integer check(@Param("id") Integer num);

    @Select({"select count(*) from daily_project p left join new_approval_process nap on p.id = nap.build_num and nap.id =( SELECT id FROM new_approval_process na WHERE nap.build_num = p.id ORDER BY id DESC LIMIT 1)where nap.user_id = #{userId} and nap.approval_status = 1  "})
    Integer findAssetsAppCount(Integer num);

    @Select({"<script>", "select d.project_name as projectName,d.id as buildNum,d.construction_unit as companyId from daily_project d <where>  <if test='buildNum != null and buildNum == null'>and d.id  = #{buildNum} </if><if test='name != null and name.length &gt; 0'>and d.project_name like '%${name}%' </if><if test='unitId != null' > and d.construction_unit  = #{unitId} </if></where> order by d.id desc</script>"})
    List<ProjectInfoVO> getProjectInfo(@Param("name") String str, @Param("buildNum") String str2, @Param("unitId") Integer num);

    @Select({"<script> SELECT count(*) FROM daily_project d <where><if test='projectName != null and projectName.length &gt; 0 ' >  d.project_name = #{projectName} </if></where></script>"})
    Integer selectByName(@Param("projectName") String str);

    @Select({"select id,construction_unit as userId from daily_project  where asset_new_status in (0,3)  "})
    List<DailyProject> daassets();

    @Update({"update daily_project set flow_no = #{flowNo} where id=#{id}"})
    Integer updateFlowNo(@Param("flowNo") String str, @Param("id") Integer num);

    @Select({"<script>", "select d.project_name as projectName,d.id as buildNum from daily_project d <where>  <if test='name != null and name.length &gt; 0'>and d.project_name like '%${name}%' </if></where> order by d.id desc</script>"})
    List<ProjectInfoVO> getProjectByName(@Param("name") String str);

    @Select({"SELECT  count(*)  FROM  assets a  LEFT JOIN daily_project dp ON dp.id = a.build_num  WHERE dp.flow_no = #{flowNo}"})
    Integer queryByFlowNo(String str);

    @Select({"select fa.* from file_attachment fa  where fa.project_id = #{projectId} and fa.file_type = 1 and fa.project_name = 'daily' "})
    @Results(value = {
            @Result(column = "project_id", property = "projectId", jdbcType = JdbcType.INTEGER),
            @Result(column = "project_name", property = "projectName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "file_type", property = "fileType", jdbcType = JdbcType.VARCHAR),
            @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR)})
    List<UploadFile> queryByProjectId(@Param("projectId") Integer projectId);
}